#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

class Solution {
public:
	void setZeroes(vector<vector<int>>& matrix) {
		vector<int> rows;
		vector<int> cols;
		vector<vector<int>> stand(matrix.size(), vector<int>(matrix[0].size()));
		for (int i = 0; i < matrix.size(); i++) {
			for (int j = 0; j < matrix[i].size(); j++) {
				if (matrix[i][j] == 0) {
					if(count(rows.begin(),rows.end(),i)==0) 
						rows.push_back(i);
					if (count(cols.begin(), cols.end(), j) == 0)
						cols.push_back(j);
				}

			}
		}
		for (int i = 0; i < matrix.size(); i++)
		{
			int c = count(rows.begin(), rows.end(), i);
			if (count(rows.begin(), rows.end(), i))
				continue;
			for (int j = 0; j < matrix[i].size(); j++) {
				if (count(cols.begin(),cols.end(),j)) 
					continue;
				stand[i][j] = matrix[i][j];
			}
		}
		matrix = stand;
	}
};

void main() {
	vector<vector<int>> test = {
		{0,1,2,0},
		{3,4,5,2},
		{1,3,1,5}
	};
	vector<vector<int>> test2 = {
		{1,1,1},
		{1,0,1},
		{1,1,1}
	};
	vector<vector<int>> test3 = {
		{0,0,0,5},
		{4,3,1,4},
		{0,1,1,4},
		{1,2,1,3},
		{0,0,1,1},
	};
	Solution s;
	s.setZeroes(test3);
	for (int i = 0; i < test3.size(); i++) {
		for (int j = 0; j < test3[i].size(); j++)
			cout << test3[i][j] << " ";
		cout << endl;
	}
}